#include <cstdio>
#include <cstring>

struct Rect
{
    int x1, y1, x2, y2;
    Rect( ) { }
    Rect( int _x1, int _y1, int _x2, int _y2 )
        : x1( _x1 ), y1( _y1 ), x2( _x2 ), y2( _y2 ) { }
};

int main( )
{
    int i, j, k, l, t, n, m, cnt;
    char s[ 101 ][ 101 ];
    Rect r[ 100 ];
    bool zm[ 27 ];
    while ( scanf("%d%d", &n, &m) )
    {
        if ( n == 0 && m == 0 )
            break;
        for ( i = 0; i < n; i++ )
            scanf("%s", s[ i ]);
        memset( zm, 0, sizeof( zm ) );
        cnt = 0;
        for ( i = 0; i < n - 2; i++ )
            for ( j = 0; j < m - 2; j++ )
                if ( s[ i ][ j ] != '.' && s[ i ][ j ] == s[ i + 1 ][ j ] && s[ i ][ j ] == s[ i ][ j + 1 ] )
                {
                    for ( k = j + 2; k < m; k++ )
                        if ( s[ i ][ k ] != s[ i ][ j ] )
                            break;
                    if ( k == j + 2 )
                        continue;
                    k--;
                    for ( l = i + 2; l < n; l++ )
                        if ( s[ l ][ j ] != s[ i ][ j ] )
                            break;
                    if ( l == i + 2 )
                        continue;
                    l--;
                    for ( t = i + 1; t <= l; t++ )
                        if ( s[ t ][ k ] != s[ i ][ j ] )
                            break;
                    if ( t <= l )
                        continue;
                    for ( t = j + 1; t <= k; t++ )
                        if ( s[ l ][ t ] != s[ i ][ j ] )
                            break;
                    if ( t <= k )
                        continue;
                    r[ cnt++ ] = Rect( i, j, l, k );
                }
        for ( i = 0; i < cnt; i++ )
        {
            zm[ s[ r[ i ].x1 ][ r[ i ].y1 ] - 'A' ] = true;
            for ( j = 0; j < cnt; j++ )
            {
                if ( i == j )
                    continue;
                if ( r[ j ].x1 > r[ i ].x1 && r[ j ].y1 > r[ i ].y1 && r[ j ].x2 < r[ i ].x2 && r[ j ].y2 < r[ i ].y2 )
                {
                    zm[ s[ r[ i ].x1 ][ r[ i ].y1 ] - 'A' ] = false;
                    continue;
                }
            }
        }
        for ( i = 0; i < 26; i++ )
            if ( zm[ i ] )
                printf("%c", i + 'A');
        printf("\n");
    }
    return 0;
}